//index.js
//获取应用实例
var app = getApp()
var pageContext
Page({
  data: {
    actionSheetHidden: true,
    actionSheetItems: [],
    selectType: {
      id: '1',
      name: "物业"
    }
  },
  // 二维码界面
  btnCreateQrcode: function() {
    wx.navigateTo({
      url: '../qrcode/qrcode'
    })
  },
  onLoad: function () {
    pageContext = this
  },
  btnChangeType: function() {
    var actionSheetItems = new Array()
    actionSheetItems[0] = {
      id: '1',
      tap: 'selectType', 
      name: '物业'
    }
    actionSheetItems[1] = {
      id: '2',
      tap: 'selectType', 
      name: '业主'
    }
    pageContext.setData({
      actionSheetItems: actionSheetItems
    })
    this.setData({
      actionSheetHidden: false
    });
  },
  selectType: function(e) {
    var selectType
    if (e.currentTarget.id == '1') {
      selectType = {
        id: '1',
        name: '物业'
      }
    } else if (e.currentTarget.id == '2') {
      selectType = {
        id: '2',
        name: '业主'
      }
    }
    this.setData({
      actionSheetHidden: true,
      selectType: selectType
    });
  },
  actionSheetTap: function(e) {
    this.setData({
      actionSheetHidden: !this.data.actionSheetHidden
    })
  },
  actionSheetChange: function(e) {
    this.setData({
      actionSheetHidden: !this.data.actionSheetHidden
    });
  },
  onShareAppMessage: function () {
    return {
      title: '二维码解锁',
      desc: '智能访客管理',
      path: '/pages/index/index'
    }
  }
})
